<template>
  <swiper :options="swiperOption" class="swiper-wrapper" v-if="showSwiper">
    <!-- slides -->
    <swiper-slide v-for="item in swiperList" :key="item.id">
      <img class="swiper-img" :src="item.imgUrl" alt="风雨廊桥">
    </swiper-slide>
    <!-- Optional controls -->
    <div class="swiper-pagination"  slot="pagination"></div>
  </swiper>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    swiperList: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true
      }
    }
  },
  computed: {
    showSwiper () {
      return this.swiperList.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  .swiper-wrapper >>> .swiper-pagination-bullet
    background: #fff
  .swiper-wrapper
    overflow: hidden
    height: 0
    padding-bottom: 31.25%
    width: 100%
    background: #eee
    .swiper-img
      width: 100%
</style>
